import 'package:changxindianzishangwu/cache/local_cache.dart';
import 'package:changxindianzishangwu/http/base/ec_base_request.dart';
import 'package:changxindianzishangwu/http/request/query_some_message.dart';
import 'package:changxindianzishangwu/http/request/save_some_message_request.dart';
import 'package:changxindianzishangwu/http/zd_net.dart';
import 'package:changxindianzishangwu/model/group_message_list_model.dart';

//
// context	内容	query	false
// string
// contextType	消息类型	query	false
// integer(int32)
// createTime	创建时间	query	false
// integer(int64)
// delTime	删除时间	query	false
// integer(int64)
// length	播放时长(s)	query	false
// integer(int32)
// receiver	接收人数	query	false
// integer(int32)
// size	文件大小	query	false
// integer(int64)
// toUsers	接收用户的userid集合用英文逗号隔开	query	false
// string
// userId	操作用户id	query	false
// integer(int32)
// delFlag
class SaveSomeMessageDao {
  static saveSomeMessage(
      {String context,
      int contextType,
      int createTime = 0,
      int delTime = 0,
      int length = 0,
      int receiver,
      StringBuffer toUsers,
      String userId,
      String OImages,
      List<String> fileinfoString}) async {
    EcBaseRequest request = SaveSomeMessageRequest();
    request
        .add("context", context)
        .add("contextType", contextType)
        .add("createTime", createTime)
        .add("delTime", delTime)
        .add("receiver", receiver)
        .add("userId", userId)
        .add("length", length)
        .add("toUsers", toUsers)
        .add("OImages", OImages)
        .add("fileinfoString", fileinfoString ?? "")
        .add("access_token", getAppLoginToken());

    var result = await ZdNet.getInstance().send(request);
    print("dsad========================" + result.toString());
    return result;
  }

  static querySomeMessages(
      {pageIndex = 0, pageSize = 20, String userId}) async {
    EcBaseRequest request = QuerySomeMessage();
    request
        .add("pageIndex", pageIndex)
        .add("pageSize", pageSize)
        .add("userId", userId)
        .add("access_token", getAppLoginToken());

    var result = await ZdNet.getInstance().send(request);
    GroupMessageListModel groupListModel =
        GroupMessageListModel.fromJson(result);
    print("sa=================" + result.toString());
    return GroupMessageListModel.fromJson(result);
  }
}
